<template>
    <div>
        <h1>登录</h1>
        <table class="table">
            <tbody>
                <tr>
                    <td>用户名</td>
                    <td>
                        <input type="text" v-model="find.name">
                    </td>
                </tr>

                <tr>
                    <td>密码</td>
                    <td>
                        <input type="password" v-model="find.pwd">
                    </td>
                </tr>

                <tr>
                    <td></td>
                    <td>
                        <input type="button" value="登录" @click="Dluser">
                    </td>
                </tr>
            </tbody>
        </table>
    </div>
</template>

<script setup lang="ts">
import {ref} from 'vue';
import axios from 'axios';
import { useRouter } from 'vue-router';

const find=ref({
    name:"",
    pwd:""
})

var touer=useRouter();
const Dluser=()=>{
    axios.get("https://localhost:7267/api/User/GetUser",{params:find.value}).then(res=>{
        if(res.data.Id==-1){
            alert("用户名错误");
            return;
        }
        if(res.data.Id==-2){
            alert("密码错误");
            return;
        }else{
            alert("登录成功");
            touer.push({path:"/list"})
        }
    })
}


</script>

<style scoped>

</style>